// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this.node.on(cc.Node.EventType.TOUCH_START, function(event) {
            console.log("點擊了一下move_scenes");
            let moveAction = cc.moveTo(1.5, cc.v2(0,0));
            this.node.runAction(moveAction);
        }, this);
        // let pos1 = cc.v2(100, 100);
        // let pos2 = cc.v2(0,0);
        // console.log(pos1.sub(pos2), "---", pos2.sub(pos1));
        // console.log(pos1.mag(pos2), "---", pos2.mag(pos1));
        // let rect1 = cc.rect(0, 0, 200, 200);
        // console.log(rect1.contains(pos1), rect1.contains(pos2));
        // let pos3 = this.node.convertToWorldSpace(cc.v2(0,0));
        // console.log(pos3);
        // console.log(this.node);
        // console.log(this.node.position, this.node.convertToWorldSpaceAR(this.node.position));
        // let box = this.node.getBoundingBox();
        // console.log("box", box);
        // let world_box = this.node.getBoundingBoxToWorld();
        // console.log("world_box", world_box);
        // var m_pos = this.node.parent.convertToNodeSpaceAR(cc.v2(900,600));
        // this.node.setPosition(m_pos);
        // console.log(m_pos);
        // let action01 = cc.moveTo(1, cc.v2(100, 100));
        // this.node.runAction(action01);
        // let action02 = cc.moveTo(1, cc.v2(100, 100));
        // this.node.runAction(action02);
        
    },

    start () {

    },

    // update (dt) {},
});
